package com.chinairi.mall.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.chinairi.mall.model.HomePicType;
import com.chinairi.mall.dao.HomePicTypeMapper;
import com.chinairi.mall.model.SysUser;
import com.chinairi.mall.service.IHomePicTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.UUID;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author Webgasd
 * @since 2020-09-09
 */
@Service
public class HomePicTypeServiceImpl extends ServiceImpl<HomePicTypeMapper, HomePicType> implements IHomePicTypeService {
    @Autowired
    private HomePicTypeMapper homePicTypeMapper;

    /**
     * 配置图片类型
     *
     * @param homePicType 图片类型对象
     */
    @Override
    public void config(HomePicType homePicType) {
        homePicType.setHomePicTypeDbid(UUID.randomUUID().toString().replace("-", ""));
        homePicTypeMapper.insert(homePicType);
    }

    /**
     * 更新图片类型表
     *
     * @param homePicType 图片类型对象
     */
    @Override
    public void update(HomePicType homePicType) {
        homePicTypeMapper.updateById(homePicType);
    }

    /**
     * 删除图片类型
     *
     * @param uuid 主键
     */
    @Override
    public void delete(String uuid) {
        homePicTypeMapper.deleteById(uuid);
    }

    /**
     * 获取所有图片类型列表
     *
     * @return list
     */
    @Override
    public List<HomePicType> get() {
        QueryWrapper<HomePicType> wrapper = new QueryWrapper<>();
        return homePicTypeMapper.selectList(wrapper);
    }
}
